'use strict';

module.exports = app => {
  const { STRING, INTEGER, DATE } = app.Sequelize;

  const User = app.model.define('user', {
    id: {
      type: INTEGER,
      primaryKey: true,
      autoIncrement: true,
      comment: '用户ID'
    },
    username: {
      type: STRING(50),
      allowNull: false,
      unique: true,
      comment: '用户名'
    },
    password: {
      type: STRING(100),
      allowNull: false,
      comment: '密码'
    },
    email: {
      type: STRING(100),
      allowNull: true,
      comment: '邮箱'
    },
<<<<<<< HEAD
=======
    role: {
      type: STRING(20),
      allowNull: false,
      defaultValue: 'user',
      comment: '角色: user(用户), enterprise(企业), admin(管理员)'
    },
    avatar: {
      type: STRING(255),
      allowNull: true,
      comment: '头像路径'
    },
>>>>>>> resume
    created_at: {
      type: DATE,
      allowNull: true,
      comment: '创建时间'
    },
    updated_at: {
      type: DATE,
      allowNull: true,
      comment: '更新时间'
    }
  }, {
    tableName: 'users',
    underscored: true
  });

  return User;
};